﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Model.Sys.Config
{
    /// <summary>
    /// 这里即使用static属性，属性的值也会随着AppSetting配置项的修改而及时修改
    /// </summary>
    public class RedisConfig
    {
        /// <summary>
        /// 可写的Redis链接地址
        /// </summary>
        public static string WriteServerList 
        {
            get
            {
                return ConfigurationManager.AppSettings["WriteServerList"];
            }
        }

        /// <summary>
        /// 可读的Redis链接地址
        /// </summary>
        public static string ReadServerList
        {
            get
            {
                return ConfigurationManager.AppSettings["ReadServerList"];
            }
        }

        /// <summary>
        /// 最大写链接数
        /// </summary>
        public static int MaxWritePoolSize
        {
            get
            {
                return int.Parse(ConfigurationManager.AppSettings["MaxWritePoolSize"]);
            }
        }

        /// <summary>
        /// 最大读链接数
        /// </summary>
        public static int MaxReadPoolSize
        {
            get
            {
                return int.Parse(ConfigurationManager.AppSettings["MaxReadPoolSize"]);
            }
        }

        /// <summary>
        /// 自动重启
        /// </summary>
        public static bool AutoStart
        {
            get
            {
                return bool.Parse(ConfigurationManager.AppSettings["AutoStart"]);
            }
        }

        /// <summary>
        /// 本地缓存到期时间，单位:秒
        /// </summary>
        public static int LocalCacheTime
        {
            get
            {
                return int.Parse(ConfigurationManager.AppSettings["LocalCacheTime"]);
            }
        }

        /// <summary>
        /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,如redis工作正常,请关闭该项
        /// </summary>
        public static bool RecordeLog
        {
            get
            {
                return bool.Parse(ConfigurationManager.AppSettings["RecordeLog"]);
            }
        }
    }
}
